<HTML><HEAD>
<!--
    ----------------
    Protected Fields
    ----------------
-->

<SCRIPT LANGUAGE="JavaScript"><!-- hide from old browsers

/*
    THE JAVASCRIPT COOKBOOK by Erica Sadun, webrx@mindspring.com
    Copyright (c)1998 by Charles River Media.  All Rights Reserved.
    
    This applet can only be re-used or modifed by license holders of the
    JavaScript Cookbook CD-ROM.  Credit must be given in the source
    code and this copyright notice must be maintained. If you do
    not hold a license to the JavaScript Cookbook, you may NOT
    duplicate or modify this code for your own use.

    Use at your own risk. No warranty is given or implied of the suitability 
    of this applet for any specific application. Neither Erica Sadun nor 
    Charles River Media will be held responsible for any unwanted effects 
    due to the use of this applet or any derivative. 
*/

<!-- done hiding --></SCRIPT></HEAD>

<BODY bgcolor="ffffff">
    
<FONT COLOR="007777"><H1><IMG SRC="../GRAFX/UTENS.JPG" WIDTH=80 HEIGHT=50
ALIGN = LEFT>Protecting a Field</H1></FONT>

<BLOCKQUOTE><FONT COLOR="770000">
Sometimes you don't want a user to be able to write into a field.
Try activating the second field. Focus will quickly
return to the first field.
</FONT>        
    
<FORM onSubmit="return false">
    <INPUT TYPE='TEXT' NAME='F1' VALUE='Text'>
</FORM><br>
<FORM onSubmit="return false">
    <INPUT TYPE='TEXT' NAME='F1' 
        onFocus="this.blur();this.value='';document.forms[0].F1.focus();document.forms[0].F1.select()">
</FORM><br>
    
</FONT></BLOCKQUOTE>

<FONT COLOR="007777"><H2>Discussion</H2></FONT>

<FONT SIZE=4>
This protection system can be bypassed if you type quickly (before
the <FONT COLOR="770000">focus</FONT> event is processed).
However, it gives a convenient, if imperfect, layer of security
to keep the reader out of protected fields.
</FONT>        

<FONT COLOR="770000"><PRE>
&lt;FORM onSubmit="return false"&gt;
    &lt;INPUT TYPE='TEXT' NAME='F1' VALUE='Text'&gt;
&lt;/FORM&gt;&lt;br&gt;
&lt;FORM onSubmit="return false"&gt;
    &lt;INPUT TYPE='TEXT' NAME='F1' 
        onFocus="this.blur();this.value='';document.forms[0].F1.focus();document.forms[0].F1.select()"&gt;
&lt;/FORM&gt;
</PRE></FONT>

<h5>Copyright &copy;1996 by Charles River Media, All Rights Reserved</h5>
</BODY>
</HTML>